//
//  UILabel+Extension.swift
//  SinaWeibo
//
//  Created by 王佳琳 on 16/2/16.
//  Copyright © 2016年 王佳琳. All rights reserved.
//

import UIKit

//给UILabel作扩展

extension UILabel {
    //类工厂方法
    class func factoryLabel(text: String, fontSize: CGFloat,textColor: UIColor) -> UILabel{
        let l = UILabel()
        l.text = text
        l.font = UIFont.systemFontOfSize(fontSize)
        l.textColor = textColor
        
        //设置行数为0 
        l.numberOfLines = 0
        //设置对齐
        l.textAlignment = .Center
        //自适应大小
        l.sizeToFit()
   
        return l
    }
    
 convenience init(text: String, fontSize: CGFloat,textColor: UIColor, alignment: NSTextAlignment = .Center) {
        
        self.init()
        
        self.text = text
        font = UIFont.systemFontOfSize(fontSize)
        self.textColor = textColor
        //设置行数为0
        numberOfLines = 0
        //设置对齐
        textAlignment = alignment
        //自适应大小
        sizeToFit()

    }
}